package com.itshidu.jiaowu.util;



import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class LoginConfiguration  implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器
        LoginInterceptor loginInterceptor = new LoginInterceptor();
        InterceptorRegistration loginRegistry = registry.addInterceptor(loginInterceptor);
        // 拦截路径
        loginRegistry.addPathPatterns("/**");
        // 排除路径
        loginRegistry.excludePathPatterns("/login");
        loginRegistry.excludePathPatterns("/register");
        loginRegistry.excludePathPatterns("/public/login");
        loginRegistry.excludePathPatterns("/public/register");
        loginRegistry.excludePathPatterns("/public/logout");
        // 排除资源请求
        loginRegistry.excludePathPatterns("/assets/**/*.css");
        loginRegistry.excludePathPatterns("/assets/**/*.js");
        loginRegistry.excludePathPatterns("/assets/js/jquery.min.js");
        loginRegistry.excludePathPatterns("/assets/**/*.png");
        loginRegistry.excludePathPatterns("/assets/**/**");
    }

}
